﻿/*
 * Copyright © 2011 Tristan Reeves, treeves@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
namespace Sprinkles.Tests.DeploymentHosts
{
    public class PropertyHost2 : DeploymentHost
    {
        public class Test1
        {
            public Test2 Test2 { get; set; }
        }
        public class Test2
        {
            public Test1 Test1 { get; set; }
        }

        public static bool Obj1_Singleton;
        public static bool Obj2_Singleton;
        public static bool DO_INCLUDE = false;

        public static string Qualify(string name)
        {
            return "PropertyHost2." + name;
        }

        protected override void RegisterDeployments()
        {
            base.Register<Test1>()
                .Name(Qualify("obj1"))
                .Singleton(Obj1_Singleton)
                .Property(x => x.Test2)
                    .SetReference(Qualify("obj2"))
                .Done();

            base.Register<Test2>()
                .Name(Qualify("obj2"))
                .Singleton(Obj2_Singleton)
                .Property(x => x.Test1)
                    .SetReference(Qualify("obj1"))
                .Done();
        }

        protected override bool Include
        {
            get { return (UserContext == "property-config-1") && DO_INCLUDE; }
        }
    }
}
